﻿@{
    ViewBag.Title = "提现";
    Layout = "~/Views/Shared/_LayoutFore.cshtml";
}

@section script{
    <script src="~/Content/assets/DatePicker/WdatePicker.js"></script>
    <script type="text/javascript">
        function sftWithDraw() {
            //先将顺序拼接好
            if ($("#sftUserId").val() == null || $("#sftUserId").val() == "") {
                $.dialog.alert("请先开通盛付通账号", function () {
                    window.location.href = "/Account/PersonalCertification";
                });
                return;
            }
            if ($("#OutPay").val() == "") {
                $.dialog.alert("请输入提现金额");
                return;
            }
            //var orderNum = CreateOrderNo();
            //var sign = "amount=" + $("#OutPay").val() + "&callback=" + $("#sftcallback").val() + "&merchantNo=" + $("#sftmerchantNo").val() + "&notifyUrl=" +
            //    $("#sftnotifyUrl").val() + "&timestamp=" + "temp" + "&userName=" + $("#sftuserName").val() + "&withdrawNo=" + orderNum;
            //sign = sign.replace(/\&/g, "|");
            //$.ajax({
            //    url: "/Account/AddWithdrawMessage",
            //    type: "Post",
            //    success: function (data) {
            //        var time = data.substring(0, 14);
            //        var sign1 = data.substring(14);
            //        $("#sfttimestamp").val(time);
            //        var orderNo = time.substring(2);
            //        orderNum = orderNum.replace("orderNum", orderNo);
            //        $("#sftwithdrawNo").val(orderNum);
            //        $("#sftsign").val(sign1);
            //        $("#sftWithdrawForm").submit();
            //    },
            //    data: "sign=" + sign + "&amount=" + $("#OutPay").val() + "&orderNo=" + orderNum,
            //});
            
            var url = "url:/Account/WithdrawMiddlePage?money=" + escape($("#OutPay").val());
            $.dialog({
                content: url,
                width: '1200px',
                height: '800px',
                lock: true,
                background: '#000', /* 背景色 */
                opacity: 0.5,       /* 透明度 */
                drag: false,
                resize: false,
                close: function () {
                    parent.location.reload();
                    return true;
                }
            });
        }

        $(function () {
            $("#OutPay").blur(function () {
                if ($("#OutPay").val() < 2) {
                    $.dialog.alert("至少提现2元");
                    return;
                }
                var balance = $("#sftbalance").val();
                if ($("#OutPay").val() > balance) {
                    $.dialog.alert("当前余额不足，请先充值");
                    return;
                }

                $("#realAmount").text($("#OutPay").val() - 2);
            });
        });

        //根据时间查询
        function withdrawSearch() {
            $("#formWithdrawTime").submit();
        }

        var util = {};
        var options = {
            listUrl: "@Url.Action("WithdrawList")"
        };

        $(document).ready(function () {
            var gridopt = {
                url: options.listUrl,
                colModel: [
                    { display: '编号', name: 'Id', width: "5%", sortable: true, hide: true, align: 'left', iskey: true },
                    { display: '日期', name: 'CreateTime', width: "20%", sortable: false, hide: false, align: 'left' },
                    { display: '类型', name: 'Type', width: "10%", sortable: false, align: 'left', process: fromatType },
                    { display: '金额', name: 'OutPay', width: "10%", sortable: false, align: 'left' },
                    { display: '支付方式', name: 'BankName', width: "10%", sortable: false, align: 'left' },
                    { display: '状态', name: 'Status', width: "10%", sortable: false, align: 'left', process: fromatStatus }
                ],
                sortname: "Id",
                sortorder: "DESC",
                title: false,
                rp: 14,
                usepager: true,
                showcheckbox: false
            };
            var xjgrid = new xjGrid("gridlist", gridopt);

            function fromatType(value, cell) {
                var ops = [];
                if (value == '2') {
                    ops.push("提现");
                } else {
                    ops.push("手续费");
                }
                return ops.join("");
            }

            function fromatStatus(value, cell) {
                var ops = [];
                if (value == '1') {
                    return "成功";
                } else {
                    ops.push("失败");
                }
                return ops.join("");
            }

            $("#formWithdrawTime").submit(function () {
                xjgrid.Query(this);
                return false;
            });
        });
    </script>
}

<div class="RightContrent">
    <div style="margin-left: 50px; margin-right: 50px;">
        <div class="line10"></div>
        <div class="line10"></div>
        <div class="tab-content">
            <div class="tab_title">@ViewBag.Title</div>
            <div class="tab-content">
                <div style="width: 16px; height: 12px; float: left;">
                    <img src="~/Content/Images/leftarraw.png" />
                </div>
            </div>
            <div class="tab-content_border">
                <input type="hidden" id="sftUserId" value="@ViewBag.SFTUserId"/>
                <input type="hidden" id="sftbalance" value="@ViewBag.balance"/>
                <form >
                    <div style="width: 70%; float: left;">
                        <dl>
                            <dt>
                                <span class="red">*</span>提&nbsp;现&nbsp;金&nbsp;额：
                            </dt>
                            <dd>
                                <input type="text" id="OutPay" autocomplete="off" onkeyup=" this.value = this.value.replace(/[^\d]/g, '') " onafterpaste="this.value=this.value.replace(/[^\d]/g,'')" class="input normal" maxlength="6" placeholder="请您输入提现金额" size="20" name="amount">元
                            </dd>
                        </dl>
                        <dl>
                            <dt>提现服务费：</dt>
                            <dd>
                                <div class="i-txt">
                                    <i class="drawcash_fee_show">2</i> 元
                                </div>
                            </dd>
                        </dl>
                        <dl>
                            <dt>实际到账金额：</dt>
                            <dd>
                                <div class="i-txt">
                                    <i class="drawcash_money_show" id="realAmount">0.00</i> 元
                                </div>
                            </dd>
                        </dl>
                        <div class="i-item-btn" style="float:none">
                            <button type="button" id="btnSftRecharge" class="btn" onclick="sftWithDraw()">申请提现</button>
                        </div>
                    </div>
                    <div style="width: 30%; float: left;">
                        <div class="listTips">
                            <p style="color: red; padding: 20px;">
                                提现说明：<br />
                                &nbsp;&nbsp;&nbsp;&nbsp; 1、在正常工作日（00:00—22:00）操作的 提现，均为次日12—17点之间到账（周五及周末操作的提现，均在下周一到账）；<br />
                                &nbsp;&nbsp;&nbsp;&nbsp; 2、充值未投标客户，充值24小时后即可进行提现操作，完成操作后需收取未投标提现金额的1%为服务费。<br />
                                &nbsp;&nbsp;&nbsp;&nbsp; 3、提现的手续费从提现金额中扣除<br />
                            </p>
                        </div>
                    </div>
                </form>
                @*<div class="line20"></div>*@
                <div class="line10"></div>
                <div class="toolbar-wrap">
                    <div id="floatHead1" class="toolbar">
                        <div class="r-list">
                            <form action="@Url.Action("WithdrawList")" method="POST" id="formWithdrawTime">
                                从<input type="text" onclick=" WdatePicker() " class="input txt" id="search_sdate" name="Sdate" placeholder="开始时间" />
                                到<input type="text" onclick=" WdatePicker() " class="input txt" id="search_edate" name="Edate" placeholder="结束时间" />
                                <input type="button" value="查询" class="btn" accesskey="S" onclick="withdrawSearch()" />
                            </form>
                        </div>
                    </div>
                </div>
                <div id="gridlist"></div>
            </div>
        </div>
    </div>
</div>

